<?php
//patikrinam ar teisingai uzkrautas puslapis
if (!defined("OK")) { header('location: ../'); }
unset($extra);

	if (ADMIN) { //ADMINAS
		$extra = "\t<th scope=\"col\" class=\"title\">IP</th>\n";
		$extra .= "\t<th scope=\"col\" class=\"title\">User Agent</th>\n";
		$q = "SELECT * FROM kas_prisijunges WHERE `timestamp`>'".$timeout."'";
		//$q = "SELECT users.id, $database.* FROM users INNER JOIN $database ON users.nick = $database.user";
	}
	elseif (LEVEL == 0) { //SVECIAS
		$q = "SELECT `id`, `uid`, `file`, `user`, `clicks`, `timestamp` FROM kas_prisijunges WHERE `timestamp`>'".$timeout."' AND user<>'' LIMIT 10";
		//$q = "SELECT users.id, `uid`, `user`, `clicks`, `timestamp` FROM users INNER JOIN $database ON users.nick = $database.user WHERE `timestamp`>'".$timeout."'";
	}
	else { //USERIS
		$q = "SELECT `id`, `uid`, `user`, `clicks`, `file`, `timestamp` FROM kas_prisijunges WHERE `timestamp`>'".$timeout."' AND user<>'' ORDER BY `clicks` ASC LIMIT 50";
		//$q = "SELECT users.id, `uid`, `user`, `clicks`, `file`, `timestamp` FROM users INNER JOIN $database ON users.nick = $database.user WHERE `timestamp`>'".$timeout."'";
	}
$result=$db->uzklausa($q) or die(klaida("Klaida",mysql_error()));
$i = '0';
$u = mysql_num_rows($result);
$content = '
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <tr bgcolor="#F8F8FB">
	    <th scope="col" class="title">Slapyvardis</th>';
	    if (!empty($extra)) { $content .= $extra; }
	    $content .= '
	    <th scope="col" class="title">Puslapis</th>
	    <th scope="col" class="title">Ping</th>
	    <th scope="col" class="title">Spaudelioja</th>
	  </tr>';
	while ($row = mysql_fetch_assoc($result)) {
		//if (!empty($row['user'])) {
			$id = $row['id']; $user = $row['user']; $uzeris = "?id,47;m,".$row['id']."";
			if (!empty($row['user'])) { $user = $row['user']; $uzeris = "?id,47;m,".$row['id'].""; }
			else { $user = 'Svečias'; /*$file = '* paslaptis *';*/ $uzeris = "?id,47;m,0"; }
			$nekvepuoja = $timestamp-$row['timestamp'];
			$nekvepuoja = date('i:s',$nekvepuoja);
			if ($nekvepuoja == '00:00') { $img = '<img src="images/icons/bullet_go.png" class="middle" alt="o" />'; }
			else { $img = '<img src="images/icons/bullet_green.png" class="middle" alt="o" />'; }
			$content .='
				<tr>
					<td class="sarasas"><div align="center">'.$img.' <a href="' . $uzeris .'">'.$user.'</a> '.(($user != "Svečias")?'<a href="?id,45;n,1;u,'.$user.'"><img src="images/pm/mail.png" alt="pm" border="0"></a>':"").'</div></td>';
					if (!empty($extra)) { 
						//Imam info 
						//$location = http_get("http://api.hostip.info/?ip=".$row['ip']);
						$location = "";
						//$contents = get_tag_contents($location, "Hostip");
						$contents = "";
						//$city = trim(get_tag_contents($contents, "gml:name"));
						$city = "";
						//$country = trim(get_tag_contents($contents, "countryAbbrev"));
						$country = "";
						//if(stristr($city, "private")) { $city = "N/A"; }
						//if(stristr($country, "xx")) { $country = "N/A"; } 
						//if(stristr($city, "Unknown City?")) { $city = "N/A"; }
						//$content .= "<td class=\"sarasas\"><div align=\"center\"><a href='http://www.dnsstuff.com/tools/whois.ch?ip=".$row['ip']."&src=ShowIP' target='_blank' title=\"header=[".$user."] body=[<br/><center>Miestas: $city <br/>Šalis: $country</center><br/>] cssbody=[sarasas] cssheader=[title] fade=[on]\">".$row['ip']."</a></div></td>";
						$content .= "<td class=\"sarasas\"><div align=\"center\"><a href='http://www.dnsstuff.com/tools/whois.ch?ip=".$row['ip']."&src=ShowIP' target='_blank' >".$row['ip']."</a></div></td>";
					}
		//}
			$content .= "<td class=\"sarasas\"><div align=\"center\"><a href='http://user-agent-string.info/?action=analyze&Fuas=".urlencode($row['agent'])."' target='_blank' title=\"header=[User Agent] body=[<br/><center>User Agent: ".$row['agent']." <br/>] cssbody=[sarasas] cssheader=[title] fade=[on]\">".trimlink($row['agent'],30)."</a></div></td>";
			$content .= '
				<td class="sarasas"><div align="center"><a href="?'.$row['file'].'"><img src="images/icons/link.png" alt="page" border="0" class="middle"/></a></div></td>
				<td class="sarasas"><div align="center">'.$nekvepuoja.'</div></td>
				<td class="sarasas"><div align="center">'.$row['clicks'].'</div></td>
			</tr>';
	}
$content .= '
	</table>';
	lentele("Prisijungę vartotojai",$content);
	mysql_free_result($result);
	unset($user,$nekvepuoja,$file,$img,$content,$i,$u,$q,$row,$extra);

?>